home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / RTLWIN16.PAK / SCODE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  11KB  |  286 lines

  1. /* $Copyright: 1994$ */
  2.  
  3. /*****************************************************************************\
  4. *                                                                             *
  5. * scode.h -     Defines standard status code services.                                            *
  6. *                                                                             *
  7. *               OLE Version 2.0                                               *
  8. *                                                                             *
  9. \*****************************************************************************/
  10.  
  11.  
  12. #ifndef __SCODE_H__
  13. #define __SCODE_H__
  14. #define __SCODE_H
  15.  
  16. //
  17. // SCODE
  18. //
  19.  
  20. typedef long SCODE;
  21. typedef SCODE *PSCODE;
  22. typedef void FAR * HRESULT;
  23. #define NOERROR 0
  24.  
  25. //
  26. //  Status values are 32 bit values layed out as follows:
  27. //
  28. //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  29. //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  30. //  +-+---------------------+-------+-------------------------------+
  31. //  |S|       Context       | Facil |               Code            |
  32. //  +-+---------------------+-------+-------------------------------+
  33. //
  34. //  where
  35. //
  36. //      S - is the severity code
  37. //
  38. //          0 - Success
  39. //          1 - Error
  40. //
  41. //      Context - context info
  42. //
  43. //      Facility - is the facility code
  44. //
  45. //      Code - is the facility's status code
  46. //
  47.  
  48. //
  49. // Severity values
  50. //
  51.  
  52. #define SEVERITY_SUCCESS    0
  53. #define SEVERITY_ERROR      1
  54.  
  55.  
  56.  
  57. #define SUCCEEDED(Status) ((SCODE)(Status) >= 0)
  58.  
  59. #define FAILED(Status) ((SCODE)(Status)<0)
  60.  
  61.  
  62. //
  63. // Return the code
  64. //
  65.  
  66. #define SCODE_CODE(sc)      ((sc) & 0xFFFF)
  67.  
  68. //
  69. //  Return the facility
  70. //
  71.  
  72. #define SCODE_FACILITY(sc)  (((sc) >> 16) & 0x1fff)
  73.  
  74. //
  75. //  Return the severity
  76. //
  77.  
  78. #define SCODE_SEVERITY(sc)  (((sc) >> 31) & 0x1)
  79.  
  80. //
  81. // Create an SCODE value from component pieces
  82. //
  83.  
  84. #define MAKE_SCODE(sev,fac,code) \
  85.     ((SCODE) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
  86.  
  87.  
  88.  
  89. // --------------------- Functions ---------------------------------------
  90.  
  91. #define GetScode(hr)        ((SCODE)(hr) & 0x800FFFFFL)
  92. #define ResultFromScode(sc) ((HRESULT)((SCODE)(sc) & 0x800FFFFFL))
  93.  
  94. STDAPI PropagateResult(HRESULT hrPrev, SCODE scNew);
  95.  
  96.  
  97. // -------------------------- Facility definitions -------------------------
  98.  
  99. #define FACILITY_NULL       0x0000 // generally useful errors ([SE]_*)
  100. #define FACILITY_RPC            0x0001 // remote procedure call errors (RPC_E_*)
  101. #define FACILITY_DISPATCH   0x0002 // late binding dispatch errors
  102. #define FACILITY_STORAGE   0x0003 // storage errors (STG_E_*)
  103. #define FACILITY_ITF            0x0004 // interface-specific errors
  104.  
  105.  
  106.  
  107. #define S_OK                0L
  108. #define S_FALSE             MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_NULL, 1)
  109.  
  110.  
  111.  
  112. // --------------------- FACILITY_NULL errors ------------------------------
  113.  
  114. #define E_UNEXPECTED        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 0xffff)
  115.                 // relatively catastrophic failure
  116.  
  117. #define E_NOTIMPL           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 1)
  118.                 // not implemented
  119.  
  120. #define E_OUTOFMEMORY       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 2)
  121.                 // ran out of memory
  122.  
  123. #define E_INVALIDARG        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 3)
  124.                 // one or more arguments are invalid
  125.  
  126. #define E_NOINTERFACE       MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 4)
  127.                 // no such interface supported
  128.  
  129.  
  130. #define E_POINTER           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 5)
  131.                 // invalid pointer
  132.  
  133. #define E_HANDLE            MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 6)
  134.                 // invalid handle
  135.  
  136. #define E_ABORT             MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 7)
  137.                 // operation aborted
  138.  
  139. #define E_FAIL              MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 8)
  140.                 // unspecified error
  141.  
  142.  
  143. #define E_ACCESSDENIED      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_NULL, 9)
  144.                 // general access denied error
  145.  
  146.  
  147. // ----------------- FACILITY_ITF errors used by OLE ---------------------
  148. //
  149. // By convention, OLE interfaces divide the FACILITY_ITF range of errors
  150. // into nonoverlapping subranges.  If an OLE interface returns a FACILITY_ITF
  151. // scode, it must be from the range associated with that interface or from
  152. // the shared range: OLE_E_FIRST...OLE_E_LAST.
  153. //
  154. // The ranges, their associated interfaces, and the header file that defines
  155. // the actual scodes are given below.
  156. //
  157.  
  158. // Generic OLE errors that may be returned by many interfaces
  159. #define OLE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0000)
  160. #define OLE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x00FF)
  161. #define OLE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0000)
  162. #define OLE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x00FF)
  163. // interfaces: all
  164. // file: ole2.h
  165.  
  166.  
  167. #define DRAGDROP_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0100)
  168. #define DRAGDROP_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x010F)
  169. #define DRAGDROP_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0100)
  170. #define DRAGDROP_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x010F)
  171. // interfaces: IDropSource, IDropTarget
  172. // file: ole2.h
  173.  
  174. #define CLASSFACTORY_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0110)
  175. #define CLASSFACTORY_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x011F)
  176. #define CLASSFACTORY_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0110)
  177. #define CLASSFACTORY_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x011F)
  178. // interfaces: IClassFactory
  179. // file:
  180.  
  181. #define MARSHAL_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0120)
  182. #define MARSHAL_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x012F)
  183. #define MARSHAL_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0120)
  184. #define MARSHAL_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x012F)
  185. // interfaces: IMarshal, IStdMarshalInfo, marshal APIs
  186. // file:
  187.  
  188. #define DATA_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0130)
  189. #define DATA_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x013F)
  190. #define DATA_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0130)
  191. #define DATA_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x013F)
  192. // interfaces: IDataObject
  193. // file: dvobj.h
  194.  
  195. #define VIEW_E_FIRST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0140)
  196. #define VIEW_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x014F)
  197. #define VIEW_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0140)
  198. #define VIEW_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x014F)
  199. // interfaces: IViewObject
  200. // file: dvobj.h
  201.  
  202. #define REGDB_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0150)
  203. #define REGDB_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x015F)
  204. #define REGDB_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0150)
  205. #define REGDB_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x015F)
  206. // API: reg.dat manipulation
  207. // file:
  208.  
  209.  
  210. // range 160 - 16F reserved
  211.  
  212. #define CACHE_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0170)
  213. #define CACHE_E_LAST    MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x017F)
  214. #define CACHE_S_FIRST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0170)
  215. #define CACHE_S_LAST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x017F)
  216. // interfaces: IOleCache
  217. // file:
  218.  
  219. #define OLEOBJ_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0180)
  220. #define OLEOBJ_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x018F)
  221. #define OLEOBJ_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0180)
  222. #define OLEOBJ_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x018F)
  223. // interfaces: IOleObject
  224. // file:
  225.  
  226. #define CLIENTSITE_E_FIRST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x0190)
  227. #define CLIENTSITE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x019F)
  228. #define CLIENTSITE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x0190)
  229. #define CLIENTSITE_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x019F)
  230. // interfaces: IOleClientSite
  231. // file:
  232.  
  233. #define INPLACE_E_FIRST MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01A0)
  234. #define INPLACE_E_LAST  MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01AF)
  235. #define INPLACE_S_FIRST MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01A0)
  236. #define INPLACE_S_LAST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01AF)
  237. // interfaces: IOleWindow, IOleInPlaceObject, IOleInPlaceActiveObject,
  238. //                 IOleInPlaceUIWindow, IOleInPlaceFrame, IOleInPlaceSite
  239. // file:
  240.  
  241. #define ENUM_E_FIRST        MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01B0)
  242. #define ENUM_E_LAST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01BF)
  243. #define ENUM_S_FIRST    MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01B0)
  244. #define ENUM_S_LAST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01BF)
  245. // interfaces: IEnum*
  246. // file:
  247.  
  248. #define CONVERT10_E_FIRST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01C0)
  249. #define CONVERT10_E_LAST   MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01CF)
  250. #define CONVERT10_S_FIRST  MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01C0)
  251. #define CONVERT10_S_LAST   MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01CF)
  252. // API: OleConvertOLESTREAMToIStorage, OleConvertIStorageToOLESTREAM
  253. // file:
  254.  
  255.  
  256. #define CLIPBRD_E_FIRST     MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01D0)
  257. #define CLIPBRD_E_LAST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01DF)
  258. #define CLIPBRD_S_FIRST     MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01D0)
  259. #define CLIPBRD_S_LAST      MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01DF)
  260. // interfaces: OleSetClipboard, OleGetClipboard, OleFlushClipboard
  261. // file: ole2.h
  262.  
  263. #define MK_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01E0)
  264. #define MK_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01EF)
  265. #define MK_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01E0)
  266. #define MK_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01EF)
  267. // interfaces: IMoniker, IBindCtx, IRunningObjectTable, IParseDisplayName,
  268. //             IOleContainer, IOleItemContainer, IOleLink
  269. // file: moniker.h
  270.  
  271.  
  272. #define CO_E_FIRST      MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01F0)
  273. #define CO_E_LAST           MAKE_SCODE(SEVERITY_ERROR,   FACILITY_ITF, 0x01FF)
  274. #define CO_S_FIRST          MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01F0)
  275. #define CO_S_LAST           MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_ITF, 0x01FF)
  276. // all Co* API
  277. // file: compobj.h
  278.  
  279.  
  280. // range 200 - ffff for new error codes
  281.  
  282.  
  283. #endif      // ifndef __SCODE_H__
  284.  
  285.  
  286.